package com.example.rabbitmq.controller.cluster;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/producer")
public class ClusterProducerController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @RequestMapping("/cluster")
    public String cluster() {
        CorrelationData correlationData = new CorrelationData("6");
        rabbitTemplate.convertAndSend("", "cluster.queue",
                "cluster test...", correlationData);
        return "发送消息成功";
    }
}
